//
//  XmoStickerView.m
//  XmoStickerView
//
//  Created by Tracy on 16/3/23.
//  Copyright © 2016年 yule. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import "XmoStickerView.h"
#import "XmoBorderView.h"
static CGFloat kXmoUserResizableViewGlobalInset           = 5.0f;
static CGFloat kXmoUserResizableViewDefaultMinWidth       = 48.0;
static CGFloat kXmoUserResizableViewInteractiveBorderSize = 25.0;

@interface XmoStickerView()
@property (nonatomic,strong,readwrite) XmoBorderView *borderView;
@property (nonatomic,strong,readwrite) XmoBorderView *limitView;
@property (nonatomic,assign,readwrite) CGFloat       detaAngle;
@property (strong, nonatomic         ) UIImageView   *resizingControl;
@property (strong, nonatomic         ) UIImageView   *deleteControl;
@property (strong, nonatomic         ) UIImageView   *reversalControl;
@end

@implementation XmoStickerView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setDefaultAttribute];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setDefaultAttribute];
    }
    return self;
}

- (void)setDefaultAttribute{
    self.borderView = [[XmoBorderView alloc] initWithFrame:CGRectInset(self.bounds, kXmoUserResizableViewGlobalInset, kXmoUserResizableViewGlobalInset)];
    self.borderView.hidden = YES;
    [self addSubview:self.borderView];
    self.limitView = [[XmoBorderView alloc] initWithFrame:CGRectInset(self.bounds, kXmoUserResizableViewGlobalInset, kXmoUserResizableViewGlobalInset)];
    self.limitView.hidden = YES;
    [self addSubview:self.limitView];
    
    if (kXmoUserResizableViewDefaultMinWidth>self.bounds.size.width*0.5) {
        self.minWidth = kXmoUserResizableViewDefaultMinWidth;
        self.minHeight = self.bounds.size.height * (kXmoUserResizableViewDefaultMinWidth/self.bounds.size.width);
    }else{
        self.minWidth = self.bounds.size.width*0.5;
        self.minHeight = self.bounds.size.width*0.5;
    }
}

@end
